﻿using SIG.Model.Identity;
using SIG.ViewModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using System.Web;
using System.Web.Http;

namespace SIG.WebMVC.Controllers.API
{
    public abstract class BaseApiController: ApiController
    {
        public AjaxResultVM AR = new AjaxResultVM();
       

        protected virtual ClaimsIdentity ClaimsIdentity
        {
            get { return User.Identity as ClaimsIdentity; }
        }

        protected string GetModelErrorMessage()
        {
            string validationErrors = string.Join("|",
                    ModelState.Values.Where(E => E.Errors.Count > 0)
                    .SelectMany(E => E.Errors)
                    .Select(E => E.ErrorMessage)
                    .ToArray());
            return validationErrors;
        }
    }
}